import urllib.request


#  <meta http-equiv="Content-type" content="text/html; charset=gb2312"/>
BASE_URL = 'https://weibo.com/login.php'
HEADER = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                  'AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/103.0.0.0 Safari/537.36',

}
ENCODE1 = 'UTF-8'
ENCODE2 = 'GB2312'

request = urllib.request.Request(url=BASE_URL, headers=HEADER)
response = urllib.request.urlopen(request)
html = response.read().decode(ENCODE2)
print(html)


# 写入磁盘
with open('weibo.html', 'w', encoding=ENCODE2) as fp:
    fp.write(html)



